package com.seur.web.login;

import org.zkoss.zk.ui.util.Initiator;
import org.zkoss.zk.ui.Page;
import org.zkoss.zk.ui.Session;
import org.zkoss.zk.ui.Executions;

/**
 * User: Diego
 * Date: 02-jun-2009
 * Time: 11:29:11
 */
public class CheckLogin implements Initiator {

    public void doInit(Page arg0, Object[] arg1) throws Exception{
		Session zkSession = Executions.getCurrent().getDesktop().getSession();
		String usuario = (String)zkSession.getAttribute("usuario");
        if (usuario == null)
            Executions.sendRedirect("/zul/login/login.zul?redirectUrl=" + arg1[0].toString());        
	}

    public void doAfterCompose(Page page) throws Exception {}

    public boolean doCatch(Throwable throwable) throws Exception {return false;}

    public void doFinally() throws Exception {   }
}
